$(document).ready(function () {

    $('#dropdown-menu').superfish({ speed: 'fast' });

    searchStyle($('#SearchText'), 'type here to search...');

    setSize();

});

function setSize() {
    // Get the computed style of the body element
    var cStyle = document.body.currentStyle||window.getComputedStyle(document.body, "");

    // Check the overflow and overflowY properties for "auto" and "visible" values
    hasVScroll = cStyle.overflow == "visible"
               || cStyle.overflowY == "visible"
               || (hasVScroll && cStyle.overflow == "auto")
               || (hasVScroll && cStyle.overflowY == "auto");


    if (hasVScroll) {
        var windowHeight = parseInt($(window).height()) - 30;
        var headerHeight = parseInt($('#header').height());
        var menuHeight = parseInt($('#dropdown-menu').height());

        $('#div-height').height(windowHeight - headerHeight - menuHeight);
    }
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function searchStyle(obj, text) {
    if (obj.attr('value') == '' || obj.attr('value') == text) {
        obj.attr('value', text);
        obj.addClass('greyText');
    } else {
        obj.removeClass('greyText');
    }

    obj.focus(function(){
        if (obj.attr('value') == text){
            obj.attr('value', '');
            obj.removeClass('greyText');
        }
    });

    obj.blur(function () {
        if (obj.attr('value').trim() == '') {
            obj.attr('value', text);
            obj.addClass('greyText');
        }
    });
};

function deleteData(){
    $('a[title=delete]').click(function (e) {

        var title = 'Delete';
        var message = 'Delete data ?';
        var ok = 'OK';
        //var url = $(this).attr('href');
		
        $.message({
            'title': title,
            'message': message,
            'width': 300,
            'buttons': { 'Cancel': { 'name': 'Cancel' },
                'OK': { 'name': 'OK', 'action': function () {
                    //window.location = url;
					alert('OK');
                }
                }
            }
        });

        e.preventDefault();
    });
};